#include <wx/wx.h>
#include "EditorCore/Actions/PropertyChangeAction.h"
#include "MainFrame.h"
#include "PropertyMapper.h"

void MainFrame::OnPropertyGridChanged( wxPropertyGridEvent& event ) {
	wxPGProperty* property = event.GetProperty();
	if( !property )
		return;

	PropertyMapper mapper;
	editor_core::Property editorProperty = mapper.ToEditorProperty( property );
	editor_core::IEntity* entity = m_propertyGridEntityViewer->GetEntity();

	editor_core::PropertyChangeAction* propertyChangeAction = new editor_core::PropertyChangeAction( entity, editorProperty );
	m_document->GetHistory()->Do( propertyChangeAction );

	Refresh();
}
